﻿<UserControl x:Class="Blackbird.Studio.View.EditModule"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:v="clr-namespace:Blackbird.Studio.View"
             mc:Ignorable="d" VerticalAlignment="Stretch"
             HorizontalAlignment="Stretch"
             d:DataContext="{Binding Source={StaticResource ResourceKey=StaticViewModel}, Path=Instance.EditableModuleViewModel}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MinWidth="300px" />
            <ColumnDefinition Width="120*" MinWidth="150" />
            <ColumnDefinition Width="*" MinWidth="150" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30px" />
            <RowDefinition Height="95*" />
        </Grid.RowDefinitions>
        <!-- Module Explorer -->
        <ScrollViewer Grid.Column="0" Grid.RowSpan="2">
            <HeaderedContentControl Header="Module Explorer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <HeaderedContentControl.HeaderTemplate>
                    <DataTemplate>
                        <Border Style="{StaticResource HeaderBorderStyle}">
                            <TextBlock HorizontalAlignment="Center" Text="Module Explorer" />
                        </Border>
                    </DataTemplate>
                </HeaderedContentControl.HeaderTemplate>
                <StackPanel Focusable="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Margin="4" Text="MultiSprites" Grid.Column="0" />
                        <Button Grid.Column="1" Command="{Binding AddSpriteCommand.Command}"
                    Style="{StaticResource PaperTreeButtonStyle}">Add</Button>
                    </Grid>
                    <TreeView ItemsSource="{Binding Path=Sprites.ViewModels}" ItemTemplate="{StaticResource ResourceKey=EntityNameNodeTemplate}" ItemContainerStyle="{StaticResource ResourceKey=TreeViewItemStyle}"></TreeView>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Margin="4" Text="Maps" Grid.Column="0" />
                        <Button Grid.Column="1" Command="{Binding AddMapCommand.Command}"
                    Style="{StaticResource PaperTreeButtonStyle}">Add</Button>
                    </Grid>
                    <TreeView ItemsSource="{Binding Path=Maps.ViewModels}" ItemTemplate="{StaticResource ResourceKey=EntityNameNodeTemplate}" ItemContainerStyle="{StaticResource ResourceKey=TreeViewItemStyle}" />

                </StackPanel>
            </HeaderedContentControl>
        </ScrollViewer>
        <GridSplitter Grid.RowSpan="2" />
        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="4px" Text="{Binding Path=Model.Name}"
               Visibility="{Binding Path=NodeDisplayVisibility}" Grid.Column="1">
      <TextBlock.InputBindings>
        <KeyBinding Command="{Binding Path=BeginRenameCommand}" Key="F2" />
        <MouseBinding Command="{Binding Path=BeginRenameCommand}" MouseAction="LeftDoubleClick" />
      </TextBlock.InputBindings>
        </TextBlock>
        <TextBox Width="Auto" Text="{Binding Path=Model.Name, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
             Margin="4px" Visibility="{Binding Path=NodeEditorVisibility}" Grid.Column="1">
            <TextBox.InputBindings>
                <KeyBinding Command="{Binding Path=EndRenameCommand}" Key="Enter" />
                <KeyBinding Command="{Binding Path=EndRenameCommand}" Key="Tab" />
            </TextBox.InputBindings>
        </TextBox>
        <Border Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" BorderBrush="Beige" BorderThickness="3px" CornerRadius="6" Visibility="{Binding SpriteVisibility}">
            <Grid>
                <v:EditableMultispriteView DataContext="{Binding Path=SelectedSprite}" />
            </Grid>
        </Border>
        <Border Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" BorderBrush="Beige" BorderThickness="3px" CornerRadius="6" Visibility="{Binding MapVisibility}">
            <Grid>
                <v:EditableLayeredMapView DataContext="{Binding Path=SelectedMap}" />
            </Grid>
        </Border>
    </Grid>
</UserControl>